def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    return True

def nearest_prime_number(input_text):
    words_dict = {
        "zero": 0, "one": 1, "two": 2, "three": 3, "four": 4,
        "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9
    }

    words = input_text.split()

    if len(words) != 3:
        return "Wrong input"

    num = 100 * words_dict.get(words[0], -1) + 10 * words_dict.get(words[1], -1) + words_dict.get(words[2], -1)

    if num < 100 or num > 999:
        return "Wrong input"

    while True:
        if is_prime(num):
            return num
        num += 1

input_text = input()
result = nearest_prime_number(input_text)
if result == "Wrong input":
    print(result)
else:
    print(result)
